package Grafo;

import javax.swing.JFrame;

import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
 
/**
 * First examples of JGraphX - Creating a simple frame that
 * contains a graph component with two vertices and an edge connecting them.
 * @author vainolo
 */
public class JGraphXLearning1 extends JFrame {
   
  private static final long serialVersionUID = 196831535599934813L;
  
 
  
  public JGraphXLearning1() {
    super("JGraphXLearning1");
    mxGraph graph = new mxGraph();
    Object defaultParent = graph.getDefaultParent();
    graph.getModel().beginUpdate();
    /** coodernadas  */
  //  int ale =  a.getAleatorio();
    Object v1 = graph.insertVertex(defaultParent, null, "A", (int)(Math.random() * 500+20), (int)(Math.random() * 500+20), 80, 30,"shape=ellipse");
    Object v2 = graph.insertVertex(defaultParent, null, "B", (int)(Math.random() * 500+20), (int)(Math.random() * 500+20), 80, 30,"shape=ellipse");
    Object v3 = graph.insertVertex(defaultParent, null, "C", (int)(Math.random() * 500+20), (int)(Math.random() * 500+20), 80, 30, "shape=ellipse");
    Object v4 = graph.insertVertex(defaultParent, null, "D", (int)(Math.random() * 500+20), (int)(Math.random() * 500+20), 80, 30, "shape=ellipse");

    graph.insertEdge(defaultParent, null, "", v1, v2);
    graph.insertEdge(defaultParent, null, "", v2, v1);
    graph.insertEdge(defaultParent, null, "", v2, v3);
    graph.insertEdge(defaultParent, null, "", v3, v4);


    graph.getModel().endUpdate();
    mxGraphComponent graphComponent = new mxGraphComponent(graph);
    getContentPane().add(graphComponent);
  }
   
  public static void main(String args[]) {
    JGraphXLearning1 frame = new JGraphXLearning1();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(800, 600);
    frame.setVisible(true);

  
  /*  System.out.println(ale);
    System.out.println(ale);
    System.out.println(ale);
   // System.out.println(numero); */
    
    
    

  }
}